Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
Cómo tener cada "resultado" (parámetros) de la API

esa es mi respuesta sin procesar de la llamada API que estoy tratando de obtener cada resultado de "bloque" con un .forEach

 const app = express(); const axios = require('axios') jobList = []; app.get('/getAPIResponse', function(req, res) { async function myFunction() { axios.get('https://api...') //res.json(body) .then((result) => { result.results.forEach((element) => { console.log(element) this.jobList.push(element) }); }) } myfunction(); }); app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`); });

pero el problema es que me dio algun error en mi terminal

 (rejection id: 2) (node:81826) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined at /Users/mac/Desktop/alternatics_test/index.js:22:24 at processTicksAndRejections (internal/process/task_queues.js:95:5) (node:81826) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3) (node:81826) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined at /Users/mac/Desktop/alternatics_test/index.js:22:24 at processTicksAndRejections (internal/process/task_queues.js:95:5) (node:81826) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)

para ser lo más claro posible, los results son la palabra clave en la API de la que me gustaría tomar cada bloque de resultados para insertarlo en mi "lista de trabajos"

Busqué por todas partes y forEach parece ser la técnica adecuada para esto...

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Estás usando el módulo axios

Eso devolverá una respuesta con el esquema de respuesta axios

Entonces, debe obtener un resultado como este result.data.results , luego puede usar la función forEach

about 4 years ago · Juan Pablo Isaza Report

0

use result.data.results.forEach

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!